﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Cloak.NUnit;
using NUnit.Framework;

namespace Cloak.Linq
{
	public class CompileTypedFunc3Parameters : Behavior
	{
		private int _value;
		private LambdaExpression _lambda;
		private Func<string, bool, char, int> _compiledLambda;

		protected override void Given()
		{
			_value = 1;
			_lambda = Expression.Lambda(
				Expression.Constant(_value),
				Expression.Parameter(typeof(string)),
				Expression.Parameter(typeof(bool)),
				Expression.Parameter(typeof(char)));
		}

		protected override void When()
		{
			_compiledLambda = _lambda.Compile<string, bool, char, int>();
		}

		[Then]
		public void Executes()
		{
			Assert.AreEqual(_value, _compiledLambda(null, false, 'A'));
		}
	}
}